export function byKeyGetPath(key: any, pageInfo: any): any {
    let path: string = ''
    pageInfo.forEach((item: any) => {
        if (item.children.length === 0) {
            if (item.menuId === key) {
                path = item.fullPath
            }
        } else {
            item.children.forEach((childItem: any) => {
                if (childItem.menuId === key) {
                    path = childItem.fullPath
                }
            })
        }
    })
    return path
}

export function byLastRouteGetKey(lastRoute: any, pageInfo: any): number | null {
    let key: number | null = null
    pageInfo.forEach((item: any) => {
        if (item.children.length === 0) {
            if (item.fullPath === lastRoute) {
                key = item.menuId
            } else {
                return ""
            }
        } else {
            item.children.forEach((childItem: any) => {
                if (childItem.fullPath === lastRoute) {
                    key = childItem.menuId
                } else {
                    return ""
                }
            })
        }
    })
    return key
}

export function byAllPageGetKey(pageInfo: any) {
    let key: number | null = null
    if (pageInfo.length != 0) {
        if (pageInfo[0].children.length == 0) {
            key = pageInfo[0].menuId
        } else {
            key = pageInfo[0].children[0].menuId
        }
    } else {
        return ""
    }
    return key
}

